{% if not api.is_object %}
static sai_status_t table_{{api.name}}_add_keys(
        _In_ const sai_{{ api.name }}_t *{{ api.name }},
        _Inout_ std::shared_ptr<p4::v1::TableEntry> matchActionEntry)
{
    auto tableEntry = {{ api.name }};
    {% include 'templates/impls/p4_table_entry_match.cpp.j2' %}

    return SAI_STATUS_SUCCESS;
}

{% endif %}
static sai_status_t dash_sai_create_{{ api.name }}(
{% if api.is_object %}
        _Out_ sai_object_id_t *{{ api.name }}_id,
        _In_ sai_object_id_t switch_id,
{% else %}
        _In_ const sai_{{ api.name }}_t *{{ api.name }},
{% endif %}
        _In_ uint32_t attr_count,
        _In_ const sai_attribute_t *attr_list)
{
    auto obj_type = (sai_object_type_t)SAI_OBJECT_TYPE_{{ api.name | upper }};

{% if api.is_object %}
    return dashSai->create({{meta_table}}, obj_type, {{ api.name }}_id, switch_id, attr_count, attr_list);
{% else %}
    std::shared_ptr<p4::v1::TableEntry> matchActionEntry = std::make_shared<p4::v1::TableEntry>();
    matchActionEntry->set_table_id({{meta_table}}.id);

    if (table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry) == SAI_STATUS_NOT_SUPPORTED)
    {
        DASH_LOG_WARN("match field in {{ api.name }} not supported, API does nothing!");
        return SAI_STATUS_SUCCESS;  // bypass, temporary workaround for issue #656
    }
    return dashSai->create({{meta_table}}, obj_type, matchActionEntry, attr_count, attr_list);
{% endif %}
}

static sai_status_t dash_sai_remove_{{ api.name }}(
        {% include 'templates/headers/sai_api_param_object_id.j2' %})
{
{% if api.is_object %}
    return dashSai->remove({{meta_table}}, {{ api.name }}_id);
{% else %}
    std::shared_ptr<p4::v1::TableEntry> matchActionEntry = std::make_shared<p4::v1::TableEntry>();
    matchActionEntry->set_table_id({{meta_table}}.id);

    if (table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry) == SAI_STATUS_NOT_SUPPORTED)
    {
        DASH_LOG_WARN("match field in {{ api.name }} not supported, API does nothing!");
        return SAI_STATUS_SUCCESS;  // bypass, temporary workaround for issue #656
    }
    return dashSai->remove({{meta_table}}, matchActionEntry);
{% endif %}
}

static sai_status_t dash_sai_set_{{ api.name }}_attribute(
        {% include 'templates/headers/sai_api_param_object_id.j2' %},
        _In_ const sai_attribute_t *attr)
{
{% if api.is_object %}
    return dashSai->set({{meta_table}}, {{ api.name }}_id, attr);
{% else %}
    std::shared_ptr<p4::v1::TableEntry> matchActionEntry = std::make_shared<p4::v1::TableEntry>();
    matchActionEntry->set_table_id({{meta_table}}.id);

    if (table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry) == SAI_STATUS_NOT_SUPPORTED)
    {
        DASH_LOG_WARN("match field in {{ api.name }} not supported, API does nothing!");
        return SAI_STATUS_SUCCESS;  // bypass, temporary workaround for issue #656
    }
    return dashSai->set({{meta_table}}, matchActionEntry, attr);
{% endif %}
}

static sai_status_t dash_sai_get_{{ api.name }}_attribute(
        {% include 'templates/headers/sai_api_param_object_id.j2' %},
        _In_ uint32_t attr_count,
        _Inout_ sai_attribute_t *attr_list)
{
{% if api.is_object %}
    return dashSai->get({{meta_table}}, {{ api.name }}_id, attr_count, attr_list);
{% else %}
    std::shared_ptr<p4::v1::TableEntry> matchActionEntry = std::make_shared<p4::v1::TableEntry>();
    matchActionEntry->set_table_id({{meta_table}}.id);

    if (table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry) == SAI_STATUS_NOT_SUPPORTED)
    {
        DASH_LOG_WARN("match field in {{ api.name }} not supported, API does nothing!");
        return SAI_STATUS_SUCCESS;  // bypass, temporary workaround for issue #656
    }
    return dashSai->get({{meta_table}}, matchActionEntry, attr_count, attr_list);
{% endif %}
}

